/*
 * @Author: Jiraiya
 * @Date: 2020-05-07 17:24:39
 * @LastEditors: Jiraiya
 * @LastEditTime: 2020-05-09 10:42:35
 * @Description: 
 */
import React, {useRef, useEffect} from 'react';
const echarts = require('echarts');
import * as graph from './options/echart';
import styles from './echart.module.css';

const Echart = ({item, type, containerStyle}) => {
    const barContainer = useRef(null);
    useEffect(()=>{
        const chart = echarts.init(barContainer.current);
        chart.setOption(graph[type](item));
    })
    return <div className={styles.container} style={containerStyle}>
        <div ref={barContainer} style={{height: '100%'}}></div>
    </div>
}

export default Echart;